import xlwt
workbook=xlwt.Workbook(encoding='utf-8')
sheet1=workbook.add_sheet('sheet1',cell_overwrite_ok=True)
d_tuple=(('序号','代码','名称'),\
        ('1','600536','中国软件'),\
        ('2','300170','汉得信息'),\
        ('3','600756','汉潮软件'),\
        ('4','300302','同有科技'))
for i in range(len(d_tuple)):
    for j in range(len(d_tuple[0])):
        sheet1.write(i,j,d_tuple[i][j])
workbook.save('stock.xls')

#
# from openpyxl import Workbook
#
# # 创建一个工作簿
# wb = Workbook()
#
# # 选择当前活跃的工作表
# ws = wb.active
#
# # 可以为工作表命名
# ws.title = "MySheet"
#
# # 写入数据
# ws['A1'] = 'Hello'
# ws['B1'] = 'World'
#
# # 保存工作簿到文件
# wb.save('my_workbook.xlsx')
